package cn.springcloud.fix.common.starter.utils.mapper;



/**
 * 简单封装Dozer, 实现深度转换Bean<->Bean的Mapper.实现:
 * <p>
 * 1. 持有Mapper的单例.
 * 2. 返回值类型转换.
 * 3. 批量转换Collection中的所有对象.
 * 4. 区分创建新的B对象与将对象A值复制到已存在的B对象两种函数.
 *//*
public class BeanMapper {

    */
/**
 * 持有Dozer单例, 避免重复创建DozerMapper消耗资源.
 *//*

    private static DozerBeanMapper dozer = new DozerBeanMapper();

    */
/**
 * 基于Dozer转换对象的类型.
 *//*

    public static <T> T map(Object source, Class<T> destinationClass) {
        return dozer.map(source, destinationClass);
    }

    */
/**
 * 基于Dozer转换Collection中对象的类型.
 *//*

    public static <T> List<T> mapList(Collection sourceList, Class<T> destinationClass) {
        List<T> destinationList = Lists.newArrayList();
        for (Object sourceObject : sourceList) {
            T destinationObject = dozer.map(sourceObject, destinationClass);
            destinationList.add(destinationObject);
        }
        return destinationList;
    }

    */
/**
 * 基于Dozer将对象A的值拷贝到对象B中.
 *//*

    public static void copy(Object source, Object destinationObject) {
        dozer.map(source, destinationObject);
    }

    */
/**
 * 对象封装成map
 *//*

    public static <T> Map<String, Object> beanToMap(T bean) {
        Map<String, Object> map = Maps.newHashMap();
        if (bean != null) {
            BeanMap beanMap = BeanMap.create(bean);
            for (Object key : beanMap.keySet()) {
                map.put(key + "", beanMap.get(key));
            }
        }
        return map;
    }

    */
/**
 * 将map装换为javabean对象
 *//*

    public static <T> T mapToBean(Map<String, Object> map, T bean) {
        BeanMap beanMap = BeanMap.create(bean);
        beanMap.putAll(map);
        return bean;
    }

    */
/**
 * 将List<T>转换为List<Map<String, Object>>
 *//*

    public static <T> List<Map<String, Object>> objectsToMaps(List<T> objList) {
        List<Map<String, Object>> list = Lists.newArrayList();
        if (objList != null && objList.size() > 0) {
            Map<String, Object> map = null;
            T bean;
            for (T anObjList : objList) {
                bean = anObjList;
                map = beanToMap(bean);
                list.add(map);
            }
        }
        return list;
    }

    */
/**
 * 将List<Map<String,Object>>转换为List<T>
 *//*

    public static <T> List<T> mapsToObjects(List<Map<String, Object>> maps, Class<T> clazz) throws InstantiationException, IllegalAccessException {
        List<T> list = Lists.newArrayList();
        if (maps != null && maps.size() > 0) {
            Map<String, Object> map = null;
            T bean = null;
            for (Map<String, Object> map1 : maps) {
                map = map1;
                bean = clazz.newInstance();
                mapToBean(map, bean);
                list.add(bean);
            }
        }
        return list;
    }
}*/

